package com.thd.filter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.core.Ordered;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

public class ObjectValueGatewayFilter implements GatewayFilter, Ordered {
    Logger logger = LoggerFactory.getLogger(ObjectValueGatewayFilter.class.getName());

    private ObjectValueGatewayFilterFactory.Config config ;
    public ObjectValueGatewayFilter(ObjectValueGatewayFilterFactory.Config config){
        this.config = config;
    }
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        logger.info("对象参数的过滤器：{},{},{}====================", config.getMessage(),config.isPostLogger(),config.isPreLogger());

        return chain.filter(exchange);
    }

    /**
     * 值越小，优先级越高
     *
     * @return
     */
    @Override
    public int getOrder() {
        return 1;
    }
}
